package com.mygdx.game;

import com.badlogic.gdx.Game;

/**
 * 游戏主程序的启动入口类, 要使用场景需要将 MainGame 改为继承 Game 抽象类
 */
public class MainGame extends Game{
    public static final float WORLD_WIDTH = 480;
    public static final float WORLD_HEIGHT = 800;

    private StartScreen startScreen; //开始场景
    private GameScreen mainScreen; //主游戏场景

    @Override
    public void create() {
        startScreen = new StartScreen(this);
        mainScreen = new GameScreen();
        setScreen(startScreen);  //设置当前场景为开始场景StartScreen
    }
    @Override
    public void dispose() {
        super.dispose();
        // 游戏程序退出时, 手动销毁还没有被销毁的场景
        if (startScreen != null) {
            startScreen.dispose();
            startScreen = null;
        }
        if (mainScreen != null) {
            mainScreen.dispose();
            mainScreen = null;
        }
    }

    public void showGameScreen() { //显示主游戏场景 MainGame
        setScreen(mainScreen);
        if (startScreen!=null)
        {
            startScreen.dispose();
            startScreen = null;
        }
    }
}
